home *** CD-ROM | disk | FTP | other *** search
- Path: newsserv.grfn.org!jlendman
- From: jlendman@grfn.org (Jeret Lendman)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Listview Problem
- Date: 1 Jan 1996 12:07:52 GMT
- Organization: Grand Rapids Free-Net
- Message-ID: <4c8iqo$h16@newsserv.grfn.org>
- NNTP-Posting-Host: freenet.grfn.org
- X-Newsreader: TIN [version 1.2 PL2]
-
- Ok, I want to thank all those who are helping. This post is to show all
- the changes that have been made. Richard Katzman was correct that the
- minlist was the wrong type to allocate for. And it has been changed.
- here is my code again with changes.
-
- I have made many comments in the code to show where the help is being
- done. Again, I feel it necessary to say thanx.
-
- struct TextAttr Topaz80 = {(STRPTR)"topaz.font",8,0,0};
-
- /*******
- makelabels is called from the main function, and is the first thing.
- Then I open libraries, screen, and window. And just before opening
- the window, I call makegadgets. I mention this because, someone
- mentioned GT_RefreshWindow/Gadgets. I create the gadget list and
- attach the list before opening the window. Refreshing should not be
- neccessary. But I could be wrong.
- *******/
-
- void makegadgets(void)
- {
- struct Gadget *qgadget;
- int *vi=NULL;
-
- vi = GetVisualInfo(xscreen, TAG_END);
- if(!vi)
- printf("Error: Get Visual Info!\n");
-
- qgadget = (struct Gadget *)CreateContext(&gadgetlist);
-
- newgadget = (struct NewGadget *)AllocVec(sizeof(struct NewGadget),
- MEMF_CLEAR);
- newgadget->ng_LeftEdge = 4;
- newgadget->ng_TopEdge = 20;
- newgadget->ng_Width = 250;
- newgadget->ng_Height = 160;
- newgadget->ng_GadgetText = NULL;
- newgadget->ng_TextAttr = &Topaz80;
- newgadget->ng_GadgetID = 1;
- newgadget->ng_Flags = 0;
- newgadget->ng_VisualInfo = vi;
-
- qgadget = CreateGadget(LISTVIEW_KIND, qgadget, newgadget, GTLV_Labels,
- namelist, TAG_END);
- }
-
- makegadgets();
- xwindow = (struct Window *)OpenWindowTags(NULL, WA_Left, 0,
- WA_Top, 0,
- WA_Width, 640,
- WA_Height, 200,
- WA_DetailPen, 2,
- WA_BlockPen, 0,
- WA_IDCMP, (LISTVIEWIDCMP) | IDCMP_RAWKEY,
- WA_Gadgets, gadgetlist,
- WA_Title, windowtitle,
- WA_CustomScreen, xscreen,
- WA_Flags, WFLG_SMART_REFRESH | WFLG_ACTIVATE);
-
- void makelabels(void)
- {
- size_t q;
- char x;
-
- xtype = 0;
- xfp = (FILE *)fopen("Xenolink:users/Userfile.xlk","rb+");
- fseek(xfp, sizeof(struct User), SEEK_SET);
-
- namelist = (struct List *)AllocVec(sizeof(struct List), MEMF_CLEAR );
- if(!namelist)
- {
- printf("Error: Allocating Memory for List!\n");
- exit(0);
- }
- else
- {
- namelist->lh_Type=0; <- I have not read anywere that suggests what
- value goes here. The book I have called
- "Mapping the Amiga" lists the different types
- of lists, but nothing for a general user list.
- I have reset this back to 0 for an unknown type.
- or should it be a 1.
-
- NewList((struct List *)namelist);
- }
-
- do
- {
- q = fread(&xuser, sizeof(struct User), 1L, xfp);
- if(q)
- {
- char *name;
-
- name = (char *)AllocVec(sizeof(xuser.Name), MEMF_CLEAR);
- if(!name)
- printf("Error: Allocating Memory for name!\n");
- namenode = (struct Node *)AllocVec(sizeof(struct Node), MEMF_CLEAR);
- if(!namenode)
- printf("Error: Allocating Memory for namenode!\n");
- namenode->ln_Name = name;
-
- for(x=0; xuser.Name[x]; x++)
- name[x] = xuser.Name[x];
-
- /**** ^^^^^^^^^^^^^^^^^^^^^^
- I am still using this method to copy because when I AllocVec space
- for the name all bytes are MEMF_CLEAR(ed). When the _for_ statment
- finishes, there are plenty of NULLs to terminate the string.
- The sizeof xuser.Name is 25 bytes for those who were wondering.
- ****/ <- I use the comment marks out of habit.
-
-
- namenode->ln_Type = 100; <- I have not read anything to tell me
- what value is proper. the value here
- is from the RKM example.
-
- AddTail((struct List *)namelist, (struct Node *)namenode);
- }
- }while(q);
-
- if(xfp)
- fclose((FILE *)xfp);
- }
-
- *****************************************************************************
-
- Does anyone have an example that could be posted that works. I can not
- find any on aminet that includes the source that has a listview.
-
- ******************************************************************************
-
- Jeret Lendman E-Mail Jlendman@grfn.org
- Grand Rapids MI.
-
-
- Long live the Amiga
- Amiga 1200 with GVP's turbo series II
- 50MHz/+8megs
-
- Loving Every Minute Of It!
-
- ******************************************************************************
-
-
-